local ADDON_NAME, ns = ...

ns.mediapath = "Interface\\AddOns\\oUF_BrethrenRF\\media\\"

ns.textures = {
	["gradient"] = ns.mediapath .. "gradient",
	["Minimalist"] = ns.mediapath .. "Minimalist",
	["Cabaret"] = ns.mediapath .. "Cabaret",
	["white"] = ns.mediapath .. "white",
}

ns.fonts = {
	["LiberationSans"]=ns.mediapath .. "LiberationSans.ttf",
	["calibri"] = ns.mediapath .. "calibri.ttf",
	["Accidental Presidency"] = ns.mediapath .. "Accidental Presidency.ttf",
	["Expressway"] = ns.mediapath .. "expressway.ttf",
	["Prototype"] = ns.mediapath .. "Prototype.ttf",
}

local SM = LibStub("LibSharedMedia-3.0", true)

if SM then
	for font, path in pairs(ns.fonts) do
		SM:Register("font", font, path)
	end

	for tex, path in pairs(ns.textures) do
		SM:Register("statusbar", tex, path)
	end
end

ns.defaults = {
	-- ****** Size Settings ******
	scale = 1.0,
	width = 120,
	height = 16, -- def ratio = 7.5
	timerBarSize = 0.08, -- This sets the heigth of the timerbar to height * value
	powerbarsize = 0.1, -- This sets the heigth of the powerbar to height * value
	iconsize = 12,
	fontsize = 10,
	symbolsize = 8,
	nameLength = 8,
	
	-- ****** Texture and Font Settings ******
	-- See see below for list
	healthTexture = "Minimalist",
	healthTexturePath = ns.mediapath .. "Minimalist",
	powerTexture =  "white",
	powerTexturePath = ns.mediapath .. "white",
	font = "LiberationSans",
	fontPath =  ns.mediapath .. "LiberationSans.ttf",
	outline = nil,
	
	
	-- ****** Color Settings ******	 
	BackgroundColor = {0, 0, 0},
	useClassColor = false, -- If true HP bar texture colors below will not be used.
	
	-- HP bar texture colors
	healthTextureColor = {.25, .25, .25},
	healthTextureColorMid = {.5, .5, 0},
	healthTextureColorEnd = {.85, 0, 0},
	
	-- Health text colors
	healthTextColor = {.85, .85, .85},
	healthTextColorMid = {.85, .85, 0},
	healthTextColorEnd = {.85, 0, 0},
	
	-- Predicted health colors
	predictedHealthColorYours = {0, .7, 0, .5},
	predictedHealthColorTheirs = {0, .9, 0, .3},
	predictedHealthTextColor = {0, .85, 0},
	
	-- Border and misc colors
	defaultTextColor = {.85,.85,.85},
	borderColor = {.45,.45,.45},
	glowColor = {0,0,0},
	powerColor = {.3, .54, .74},
	aggroColor = {.85,0,0},
	dispelColors = { 
		Magic = {0,.45,1,1},
		Poison = {0,1,.22,1},
		Curse = {.75,0,1,1},
		Disease = {.8,1,0,1},
	},
	
	bossDebuffBarColorAmplification = 0.15, -- Used to amplify the color of the top bar, so it is easier to see in contrast to the background, when it is being used to display boss debuffs. 
	bossDebuffBarAlpha = 1.0,
	
	-- ***** Feature Toggles *****
	borderGlow = false,
	fontShadow = true,
	
	-- Powerbar
	powerbar = false,
	powerclass = true,
	onlyMana = true,
	
	-- HealPrediction
	healPrediction = true,
	healPredictionText = true,
	healPredictionOverflow = false,

	-- Group number / buff counter
	displayGroupNumber = false,
	displayBuffCounter = true,
	displayNonClassBuffs = false,
	UseTopBarForBossDebuffs = true,
	
	-- Windows toggles
	solo = false,
	raid = true,
	player = true,
	party = true,
	pets = false,
	MT = true,
	lfdIcon = false,
	leadIcon = true,
	showToolTip = false,
	moveBossSpecialFrame = true,
	
	-- Windows grouping & growth settings.
	numCol = 5,
	numUnits = 5, -- number of units per col, only used when splitGroups is false
	spacing = 3,
	splitGroups = true, -- use this to slip raid into groups
	HorizontalGroupGrowth = false, -- If false groups are columns, if true group are rows
	growthDirection = "RIGHT", -- Valid values: "RIGHT" or "LEFT" when HorizontalGroupGrowth is true and "RIGHT", "LEFT", "UP", "DOWN" when HorizontalGroupGrowth is false.
	sortMethod = "INDEX",
	
	-- Range distances
	inRange = 1,
	outsideRange = 0.5,	
}

function ns.InitDB()
	_G[ADDON_NAME.."DB"] = _G[ADDON_NAME.."DB"] or {}
	ns.db = _G[ADDON_NAME.."DB"]
	
	-- set correct defaults when switching over to libSM
	if not ns.db.healthTexturePath then
		ns.db.healthTexture = nil
		ns.db.powerTexture = nil
		ns.db.font = nil
	end
	
	for k, v in pairs(ns.defaults) do
		if(type(_G[ADDON_NAME.."DB"][k]) == 'nil') then
			_G[ADDON_NAME.."DB"][k] = v
		end
	end
end

function ns.restoreDB()
print("moo")
	_G[ADDON_NAME.."DB"] = nil
	ReloadUI()
end
